
"""
可迭代：
__iter__()

迭代器：
__next__()
__iter__()
"""
class MyIterable:
    def __init__(self, data):
        self.data = data

    def __iter__(self):
        return iter(self.data)


my_iterable = MyIterable([1, 2, 3])
for item in my_iterable:
    print(item)


# 迭代器
#     def __next__(self):
#         if self.index < len(self.data):
#             value = self.data[self.index]
#             self.index += 1
#             return value
#         else:
#             raise StopIteration


